<?php
namespace KontrolnoNomerDve\Client;

use KontrolnoNomerDve\Bank\Bank_products\Deposit;
use KontrolnoNomerDve\Bank\Bank_products\Credit;
class Client
{
	private $name;
	private $address;
	private $monthlySalary;
	private $nalichnost;
	private $listDeposits = array();
	private $listCredists = array();
	
	public function __construct($name, $address, $monthlySalary, $nalichnost)
	{
		$this->setName($name);
		$this->setAddress($address);
		$this->setMonthlySalary($monthlySalary);
		$this->setListCredits($listCredits);
		$this->setListDeposits($listDeposits);
		
		echo "New person created - $name";
		
	}
	
	public function getName()
	{
		return $this->name;
	}
	
	public function getAddress()
	{
		return $this->address;
	}
	
	public function getMonthlySalary()
	{
		return $this->monthlySalary;
	}
	
	public function getListDeposits()
	{
		return $this->address;
	}
	
	public function getListCredits()
	{
		return $this->listCredists;
	}
	
	public function getNalichnost()
	{
		return $this->nalichnost;
	}

	public function setName($name)
	{
		if(is_string($name) && strlen($name) > 1)
			{
				$this->name = $name;
			}else 
			{
				throw new Exception("<p>Invalid client's name!</p>") ;
			}
	}
	
	public function setAddress($address)
	{
		if(is_string($address) && strlen($address) > 5)
		{
			$this->address = $address;
		}else
		{
			throw new Exception("<p>Invalid client's address!</p>") ;
		}
	}
	
	public function setNalichnost($nalichnost)
	{
		if (is_numeric($nalichnost))
		{
			$this->nalichnost = $nalichnost;
		}
		else
		{
			throw new Exception("Invalid entry for nalichnost!");
		}
	}
	
	public function setMonthlySalary($monthlySalary)
	{
		if(is_numeric($monthlySalary) && $monthlySalary > 200)
		{
			$this->monthlySalary = $monthlySalary;
		}else
		{
			throw new Exception("<p>Invalid entry for monthly salary!</p>") ;
		}
		
	}

	public function setListDeposits($listDeposits)
	{
		if (is_array($listDeposits))
		{
			$this->listDeposits = $listDeposits;
		}else 
		{
			throw new Exception("Invalid clients deposit list!");
		}	
	}
	
	public function setListCredits($listCredits)
	{
		if (is_array($listCredits))
		{
			$this->listCredists = $listCredits;
		}else 
		{
			throw new Exception("Invalid clients credit list!");
		}
	}
	
	public function addDeposit(Bank $deposit)
	{
		$deposit->addNewDeposit($deposit);
		$listDeposits[] = $deposit;
		
	}
	
	public function otpuskaneCredit()
	{
		$goodToGo = false;
		
	}
	
	public function vnasqnePariCredit(Credit $payment)
	{
		$payment->getPaymentCredit();
		$payment->getCreditAmount();
		$newAmount = $payment->getCreditAmount() - $payment->getPaymentCredit();
	}
	
	
	
	
	
	
}

?>